package com.xbongbong.pro.enums.menu.enums;

import com.xbongbong.paas.enums.MenuTypeEnum;
import com.xbongbong.pro.enums.AccessLinkEnum;
import com.xbongbong.saas.enums.XbbRefTypeEnum;
import lombok.Getter;

/**
 * @author 吴峰
 * @version v1.0
 * @date 2019/11/28 21:15
 * @since v1.0
 */
@Getter
public enum JXCRemouldMenuEnum {

    /**
     * 
     */
    INSTOCK(XbbRefTypeEnum.INSTOCK.getName(), XbbRefTypeEnum.INSTOCK.getAlias(), XbbRefTypeEnum.INSTOCK.getCode(),
            AccessLinkEnum.INSTOCK_MANAGEMENT,
            "", MenuTypeEnum.GROUP.getType()),
    // 采购入库单
    PURCHASE_INSTOCK(XbbRefTypeEnum.PURCHASE_INSTOCK.getName(), XbbRefTypeEnum.PURCHASE_INSTOCK.getAlias(), XbbRefTypeEnum.PURCHASE_INSTOCK.getCode(),
            AccessLinkEnum.PURCHASE_INSTOCK,
            XbbRefTypeEnum.INSTOCK.getAlias(), MenuTypeEnum.FORM.getType()),
    // 销售退货入库
    REFUND_INSTOCK(XbbRefTypeEnum.REFUND_INSTOCK.getName(), XbbRefTypeEnum.REFUND_INSTOCK.getAlias(), XbbRefTypeEnum.REFUND_INSTOCK.getCode(),
            AccessLinkEnum.REFUND_INSTOCK,
            XbbRefTypeEnum.INSTOCK.getAlias(), MenuTypeEnum.FORM.getType()),
    // 生产入库单
    PRODUCTION_INSTOCK(XbbRefTypeEnum.PRODUCTION_INSTOCK.getName(), XbbRefTypeEnum.PRODUCTION_INSTOCK.getAlias(), XbbRefTypeEnum.PRODUCTION_INSTOCK.getCode(),
            AccessLinkEnum.PRODUCTION_INSTOCK,
            XbbRefTypeEnum.INSTOCK.getAlias(), MenuTypeEnum.FORM.getType()),
    // 生产退料单
    RETURNED_MATERIEL_INSTOCK(XbbRefTypeEnum.RETURNED_MATERIEL_INSTOCK.getName(), XbbRefTypeEnum.RETURNED_MATERIEL_INSTOCK.getAlias(), XbbRefTypeEnum.RETURNED_MATERIEL_INSTOCK.getCode(),
            AccessLinkEnum.RETURNED_MATERIEL_INSTOCK,
            XbbRefTypeEnum.INSTOCK.getAlias(), MenuTypeEnum.FORM.getType()),
    // 出库单
    OUTSTOCK(XbbRefTypeEnum.OUTSTOCK.getName(), XbbRefTypeEnum.OUTSTOCK.getAlias(), XbbRefTypeEnum.OUTSTOCK.getCode(),
            AccessLinkEnum.OUTSTOCK_MANAGEMENT,
            "", MenuTypeEnum.GROUP.getType()),

    // 销售出库单
    CONTRACT_OUTSTOCK(XbbRefTypeEnum.CONTRACT_OUTSTOCK.getName(), XbbRefTypeEnum.CONTRACT_OUTSTOCK.getAlias(), XbbRefTypeEnum.CONTRACT_OUTSTOCK.getCode(),
            AccessLinkEnum.CONTRACT_OUTSTOCK,
            XbbRefTypeEnum.OUTSTOCK.getAlias(), MenuTypeEnum.FORM.getType()),
    // 采购退货出库单
    RETURNED_PURCHASE_OUTSTOCK(XbbRefTypeEnum.RETURNED_PURCHASE_OUTSTOCK.getName(), XbbRefTypeEnum.RETURNED_PURCHASE_OUTSTOCK.getAlias(), XbbRefTypeEnum.RETURNED_PURCHASE_OUTSTOCK.getCode(),
            AccessLinkEnum.RETURNED_PURCHASE_OUTSTOCK,
            XbbRefTypeEnum.OUTSTOCK.getAlias(), MenuTypeEnum.FORM.getType()),
    // 生产领料单
    PRODUCTION_MATERIEL_OUTSTOCK(XbbRefTypeEnum.PRODUCTION_MATERIEL_OUTSTOCK.getName(), XbbRefTypeEnum.PRODUCTION_MATERIEL_OUTSTOCK.getAlias(), XbbRefTypeEnum.PRODUCTION_MATERIEL_OUTSTOCK.getCode(),
            AccessLinkEnum.PRODUCTION_MATERIEL_OUTSTOCK,
            XbbRefTypeEnum.OUTSTOCK.getAlias(), MenuTypeEnum.FORM.getType()),
    // 工单出库单
    WORK_ORDER_OUTSTOCK(XbbRefTypeEnum.WORK_ORDER_OUTSTOCK.getName(), XbbRefTypeEnum.WORK_ORDER_OUTSTOCK.getAlias(), XbbRefTypeEnum.WORK_ORDER_OUTSTOCK.getCode(),
            AccessLinkEnum.WORK_ORDER_OUTSTOCK,
            XbbRefTypeEnum.OUTSTOCK.getAlias(), MenuTypeEnum.FORM.getType()),
    ;

    /**
     * saas应用标示解释
     */
    private String name;
    /**
     * saas应用标示
     * @see XbbRefTypeEnum
     */
    private String alias;
    /**
     * @see XbbRefTypeEnum
     */
    private Integer code;
    /**
     * 对应的链接
     */
    private AccessLinkEnum accessLinkEnum;

    /**
     * 父节点，如果没有父节点，则此值为空字符串
     */
    private String parent;
    /**
     * 类型
     * @see MenuTypeEnum
     */
    private Integer type;

    JXCRemouldMenuEnum(String name, String alias, Integer code, AccessLinkEnum accessLinkEnum, String parent, Integer type){
        this.name = name;
        this.alias = alias;
        this.code = code;
        this.accessLinkEnum = accessLinkEnum;
        this.parent = parent;
        this.type = type;
    }

    public static JXCRemouldMenuEnum getByAlias(String alias) {
        for (JXCRemouldMenuEnum jxcMenuEnum: values()) {
            if(jxcMenuEnum.getAlias().equals(alias)) {
                return jxcMenuEnum;
            }
        }
        return null;
    }

    public static JXCRemouldMenuEnum getByCode(Integer code) {
        for(JXCRemouldMenuEnum jxcMenuEnum: values()) {
            if(jxcMenuEnum.getCode().equals(code)){
                return jxcMenuEnum;
            }
        }
        return null;
    }
}
